package com.ruoyi.web.controller.djb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.djb.domain.DjbVisitorRegistryManage;
import com.ruoyi.djb.mapper.DjbVisitorRegistryManageMapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 访客审核管理Controller
 * 
 * @author xxd
 * @date 2024-01-30
 */
@Controller
@RequestMapping("/djb/visitorManage")
public class DjbVisitorRegistryManageController extends BaseController
{
    private String prefix = "djb/visitorManage";

    @Autowired
    private DjbVisitorRegistryManageMapper djbVisitorRegistryManageService;

    @RequiresPermissions("djb:visitorManage:view")
    @GetMapping()
    public String visitorManage()
    {
        return prefix + "/visitorManage";
    }

    /**
     * 查询访客审核管理列表
     */
    @RequiresPermissions("djb:visitorManage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DjbVisitorRegistryManage djbVisitorRegistryManage)
    {
        startPage();
        List<DjbVisitorRegistryManage> list = djbVisitorRegistryManageService.selectDjbVisitorRegistryManageList(djbVisitorRegistryManage);
        return getDataTable(list);
    }

    /**
     * 导出访客审核管理列表
     */
    @RequiresPermissions("djb:visitorManage:export")
    @Log(title = "访客审核管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DjbVisitorRegistryManage djbVisitorRegistryManage)
    {
        List<DjbVisitorRegistryManage> list = djbVisitorRegistryManageService.selectDjbVisitorRegistryManageList(djbVisitorRegistryManage);
        ExcelUtil<DjbVisitorRegistryManage> util = new ExcelUtil<DjbVisitorRegistryManage>(DjbVisitorRegistryManage.class);
        return util.exportExcel(list, "访客审核管理数据");
    }

    /**
     * 新增访客审核管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存访客审核管理
     */
    @RequiresPermissions("djb:visitorManage:add")
    @Log(title = "访客审核管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DjbVisitorRegistryManage djbVisitorRegistryManage)
    {
        return toAjax(djbVisitorRegistryManageService.insertDjbVisitorRegistryManage(djbVisitorRegistryManage));
    }

    /**
     * 修改访客审核管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        DjbVisitorRegistryManage djbVisitorRegistryManage = djbVisitorRegistryManageService.selectDjbVisitorRegistryManageById(id);
        mmap.put("djbVisitorRegistryManage", djbVisitorRegistryManage);
        return prefix + "/edit";
    }

    /**
     * 修改保存访客审核管理
     */
    @RequiresPermissions("djb:visitorManage:edit")
    @Log(title = "访客审核管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DjbVisitorRegistryManage djbVisitorRegistryManage)
    {
        return toAjax(djbVisitorRegistryManageService.updateDjbVisitorRegistryManage(djbVisitorRegistryManage));
    }

//    /**
//     * 删除访客审核管理
//     */
//    @RequiresPermissions("djb:visitorManage:remove")
//    @Log(title = "访客审核管理", businessType = BusinessType.DELETE)
//    @PostMapping( "/remove")
//    @ResponseBody
//    public AjaxResult remove(String ids)
//    {
//        return toAjax(djbVisitorRegistryManageService.deleteDjbVisitorRegistryManageByIds(ids));
//    }
}
